# 使用枚举类
from enum import Enum, unique
Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))

for name, member in Month.__members__.items():
    print(name, '=>', member, ',', member.value)
    
print(Month.Feb)

@unique     # @unique装饰器可以帮助我们检查保证没有重复值
class Weekday(Enum):    # 从Enum派生出自定义类
    Sun = 0     #  默认值被设置为0
    Mon = 1
    Tue = 2
    Wed = 3
    Thu = 4
    Fri = 5
    Sat = 6;
print(Weekday.Mon)
print(Weekday['Tue'])
print(Weekday.Wed.value)
print(Weekday(5))

for name, member in Weekday.__members__.items():
    print(name, '=>', member, ',', member.value)
    

